package com.justnow.offer;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

/**
 * @author justnow
 * Created on 2020-09-18
 * Description
 */
public class Ali01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int d = scanner.nextInt();
        int[] location = new int[n];
        int[] score = new int[n];

        for (int i = 0; i < n; i++) {
            location[i] = scanner.nextInt();
        }

        for (int i = 0; i < n; i++) {
            score[i] = scanner.nextInt();
        }


        int start = 0;
        int times = 0;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            int max = 0;
            for (int j = i; j < n; j++) {
                if (Math.abs(location[i] - start) <= d) {
                    if (score[i] > max) {
                        max = score[i];
                        start = i;
                    }
                }
            }
            sum += max;
            times++;
        }
    }
}
